<?php
namespace app\common\behavior;

use think\Response;
use think\Request;

class ResponseJson
{
    protected static $frontendName = ['api'];

    public function run(&$response)
    {
        $module = Request::instance()->module();
        if (in_array($module, self::$frontendName)) {
            $data = $response->getData();
            if (is_array($data)) {
                $response = Response::create($data, 'json');
            }
        }
    }
}